package com.shadow.study.test;

import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

import java.util.Properties;
import java.util.ResourceBundle;

@Slf4j
public class LdapHandler {

    /* 使用环境. */
    @Getter
    private String environment = "zone";
//
//    private LdapHandler handler;
//
//    public LdapHandler getHandler() {
//        if (handler == null) {
//            LdapHandler.init(null);
//        }
//        return handler;
//    }

    public void init() {
        log.info("init ldap handler");
        ResourceBundle rb = ResourceBundle.getBundle("ldap");
        Properties p = new Properties();
        p.put("ldap.environment", rb.getString("ldap.environment"));

        String env = (String) p.get("ldap.environment");
        final LdapHandler ldapHandler = new LdapHandler();
        ldapHandler.environment = env;
    }

    public void close() {
        log.info("close ldap handler");
    }
}
